<?php
header("Content-Type: text/html; charset=utf-8");
require_once '../smarty/Smarty.class.php';
require_once '../lib/pagination.php';
require_once '../lib/query_railway.php';
require_once '../lib/base.php';
$user=$_SESSION["RU"];
//var_dump($user);
if(!$user)header("Location:../user/login.php");
if($user["nick"]!="admin")exit;
if($_POST["act"]=="del") {
	$rid=$_POST["i"];
	$str="id=$rid";
	$op= QR::del_data($tb_border_end,$str);
	if($op>0)echo "100" ;else echo "删除失败！或许数据已经被删除！";
	exit;
}
$p=($_GET["p"]==null)|($_GET["p"]==0) ?1:$_GET["p"];
$PAGE_NUM=15;
$from=($p-1)*$PAGE_NUM;

//$sz=htmlspecialchars( $_GET["sz"]);
$zz=htmlspecialchars($_GET["zz"]);
$zc=htmlspecialchars($_GET["zc"]);
$ze=htmlspecialchars($_GET["ze"]);
$str=" $tb_end.en=$tb_border_end.end";
if ($ze.$zz.$zc){
	if($zz)$str.=" and border like '%$zz%'";
	if($zc)$str.=" and $tb_end.code like '%$zc%'";
	if($ze)$str.=" and $tb_end.en like '%$ze%'";
}
$dbtable ="$tb_border_end,$tb_end";
$count=QR::get_total($dbtable, $str);//all_number
//echo "<br/>".$count."<br/>";
$field="$tb_border_end.id,start,border,end,p20,p40gp,p40hc,box,ctime,stime,remark";
$str.=" order by ctime";
$data=QR::get_data($dbtable, $field,$str,$from,$PAGE_NUM);//all_data
//var_dump($data);

$tran=QR::get_field($tb_border,"cn");
$end=QR::get_field($tb_end,"en");
$smarty = new Smarty;
$smarty->assign("leftpanel",leftpanel("RW",6));
$smarty->assign("userdata",$data);
$smarty->assign("pagination", getPageNavigation($p,$count,$PAGE_NUM));
$smarty->assign("start",json_encode($start));
$smarty->assign("tran",$tran);
//$smarty->assign("end",json_encode($end));
$smarty->assign("zz",$zz);
$smarty->assign("zc",$zc);
$smarty->assign("ze",$ze);
$smarty->assign("user",$user);
$smarty->display('railway_list_ze.tpl');
?>